package vista;

import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import controlador.ControladorJugador;
import bean.Cronometro;
import bean.JTextFieldValidator;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaJugador extends javax.swing.JFrame {
	private JPanel panPanel;
	private JLabel lblTitulo;
	private JLabel lblCedula;
	private JLabel lblNombre;
	private JLabel lblApellido;
	private JTextFieldValidator txtCedula;
	private JTextFieldValidator txtNombre;
	private JTextFieldValidator txtApellido;
	private JButton btnIncluir;
	private JButton btnCancelar;
	Cronometro tiempo;
	private JLabel jLabelrellene;
	private JLabel jLabelfelicidades;

	public VistaJugador(Cronometro time) {
		super();
		initGUI();
		tiempo = time;
		double o = tiempo.getContador();
		String a = tiempo.convertirTiempo(o);
		lblTitulo.setText(String.valueOf(a));
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			getContentPane().setBackground(new java.awt.Color(128,0,0));
			setTitle("Registrar Jugador");
			{
				lblTitulo = new JLabel();
				lblTitulo.setText("");
				getContentPane().add(lblTitulo);
				lblTitulo.setBounds(34, 74, 310, 32);
				lblTitulo.setFont(new java.awt.Font("DejaVu Sans",1,16));
			}		
			{
				panPanel = new JPanel();
				getContentPane().add(panPanel);
				panPanel.setBounds(34, 147, 384, 131);
				panPanel.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				panPanel.setLayout(null);
				panPanel.setBackground(new java.awt.Color(0,64,128));
				{
					lblCedula = new JLabel();
					panPanel.add(lblCedula);
					lblCedula.setText("Cedula");
					lblCedula.setBounds(19, 29, 64, 15);
					lblCedula.setFont(new java.awt.Font("Dialog",0,12));
				}
				{
					txtCedula = new JTextFieldValidator();
					panPanel.add(txtCedula);
					txtCedula.setBounds(87, 25, 119, 22);
					txtCedula.setMaximaLongitud(8);
					txtCedula.setTipoCaracteresPermitidos(JTextFieldValidator.SOLO_NUMEROS);
				}							
				{
					lblNombre = new JLabel();
					panPanel.add(lblNombre);
					lblNombre.setText("Nombre");
					lblNombre.setBounds(21, 65, 54, 13);
					lblNombre.setFont(new java.awt.Font("Dialog",0,12));
				}
				{
					txtNombre = new JTextFieldValidator();
					panPanel.add(txtNombre);
					txtNombre.setMaximaLongitud(50);
					txtNombre.setTipoCaracteresPermitidos(JTextFieldValidator.LETRAS_Y_ESPACIOS);
					txtNombre.setBounds(87, 60, 265, 22);
				}				
				{
					lblApellido = new JLabel();
					panPanel.add(lblApellido);
					lblApellido.setText("Apellido");
					lblApellido.setBounds(23, 100, 79, 15);
					lblApellido.setFont(new java.awt.Font("Dialog",0,12));					
				}
				{
					txtApellido = new JTextFieldValidator();
					panPanel.add(txtApellido);
					txtApellido.setBounds(87, 97, 263, 22);
					txtApellido.setMaximaLongitud(50);
					txtApellido.setTipoCaracteresPermitidos(JTextFieldValidator.LETRAS_Y_ESPACIOS);
				}		
			}			

			{
				btnIncluir = new JButton();
				getContentPane().add(btnIncluir);
				btnIncluir.setText("Incluir");
				btnIncluir.setBounds(104, 290, 102, 29);
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(242, 290, 108, 29);				
			}
			{
				jLabelfelicidades = new JLabel();
				getContentPane().add(jLabelfelicidades);
				jLabelfelicidades.setText("Felicidades! Haz ganado. Tu tiempo es:");
				jLabelfelicidades.setBounds(34, 19, 280, 40);
			}
			{
				jLabelrellene = new JLabel();
				getContentPane().add(jLabelrellene);
				jLabelrellene.setText("Rellena tus datos");
				jLabelrellene.setBounds(34, 119, 151, 16);
			}

			pack();
			this.setSize(601, 372);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
  	
	public void addListener(ActionListener actionListener) {
		btnIncluir.addActionListener(actionListener);
		btnCancelar.addActionListener(actionListener);		
	}

	public void mostrarMensaje(String mensaje) {
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public String getCedula() {
		return txtCedula.getText();
	}

	public String getNombre() {
		return txtNombre.getText();
	}

	public String getApellido() {
		return txtApellido.getText();
	}
	
	
	public void borrarDatos()
	{
		txtNombre.setText("");
		txtApellido.setText("");		
	}
	
}
